<template>
  <div class="app-container">
    <el-table
      v-loading="listLoading"
      :data="list"
      element-loading-text="Loading"
      border
      fit
      highlight-current-row
    >
      <el-table-column align="center" label="ID" width="95">
        <template slot-scope="scope">
          {{ scope.$index }}
        </template>
      </el-table-column>
      <el-table-column label="用户名" align="center">
        <template slot-scope="scope">
          {{ scope.row.userName }}
        </template>
      </el-table-column>
      <el-table-column label="生物特征" width="150" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.bioType }}</span>
        </template>
      </el-table-column>
      <el-table-column label="软生物特征" width="150" align="center">
        <template slot-scope="scope">
          {{ scope.row.softBioType }}
        </template>
      </el-table-column>
      <el-table-column class-name="status-col" label="认证状态" width="150" align="center">
        <template slot-scope="scope">
          <el-tag :type="scope.row.status | statusFilter">{{ scope.row.status }}</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="请求网址" width="200" align="center">
        <template slot-scope="scope">
          {{ scope.row.requestNetwork }}
        </template>
      </el-table-column>
      <el-table-column align="center" prop="created_at" label="请求时间" width="200">
        <template slot-scope="scope">
          <i class="el-icon-time" />
          <span>{{ scope.row.requestTime }}</span>
        </template>
      </el-table-column>
      <el-table-column label="认证耗时" width="110" align="center">
        <template slot-scope="scope">
          {{ scope.row.duringTime }} ms
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
// import { getBioAuthData } from '@/api/table'
import { getBioAuthData } from '@/api/bio-auth'

export default {
  filters: {
    statusFilter(status) {
      const statusMap = {
        success: 'success',
        failed: 'danger'
      }
      return statusMap[status]
    }
  },
  data() {
    return {
      list: null,
      listLoading: true
    }
  },
  created() {
    this.fetchData()
  },
  methods: {
    fetchData() {
      this.listLoading = true
      getBioAuthData().then(response => {
        this.list = response.data.items
        this.listLoading = false
      })
    }
  }
}
</script>
